package com.henme.crm.util.aop;

import com.henme.crm.util.datasource.MyBatisDataSourceContextHolder;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;


@Aspect
@Component
public class DataSourceAspect {

    private static final Logger logger = LoggerFactory.getLogger(DataSourceAspect.class);

    @Before("within(@org.springframework.stereotype.Service *) && @annotation(dataSourceAnnotation)")
    public void logBefore(JoinPoint joinPoint, DataSourceAnnotation dataSourceAnnotation) {
        MyBatisDataSourceContextHolder.setDataSourceType(dataSourceAnnotation.value());
        logger.info(" aop 调用了"+joinPoint.getSignature().toString());
    }


}
